Skip to content

refactor(ci): inline bun setup, gate cache on snapshot#281

Merged
wyattjoh merged 6 commits into
mainfrom
wyattjoh/refactor-setup-bun-cache
May 13, 2026
Merged

refactor(ci): inline bun setup, gate cache on snapshot#281
wyattjoh merged 6 commits into
mainfrom
wyattjoh/refactor-setup-bun-cache

Conversation

@wyattjoh
Copy link
Copy Markdown
Contributor

@wyattjoh wyattjoh commented May 12, 2026

Summary

Drops the .github/actions/setup-bun composite action and inlines its three operations (oven-sh/setup-bun@v2, actions/cache/restore@v5, bun install --frozen-lockfile) at all eight call sites. In ci.yml's build, lint, test, and test-e2e jobs, the cache restore step is gated on github.event_name != 'issue_comment' so the snapshot path — which checks out PR-author-controlled code in the default branch's privileged context via release.yml's workflow_call — never consumes the cache. The other workflows (release.yml versioning + canary-version, notify-failure, notify-release) inline directly without a gate because they only run on trusted triggers. Cache population continues to live in the standalone warm-bun-cache.yml workflow that runs solely on push to main.

Test plan

  • Local CI suite passes (bun run format:check, bun run lint, bun run typecheck, bun run test).
  • CodeQL re-scan on the PR clears the three remaining actions/cache-poisoning/poisonable-step alerts.
  • On merge to main, Warm Bun cache runs and the next PR build reads the warmed cache.

wyattjoh added 3 commits May 12, 2026 13:02
The composite previously used actions/cache@v5 (full) which auto-saves at
job end, allowing PR-controlled code to write into the cache before save.
Use actions/cache/restore@v5 for reads and gate actions/cache/save@v5 on
github.event_name != 'pull_request' so only trusted runs (push to main,
workflow_call from release.yml) populate the cache.
- Gate the save step on the restore step's cache-hit output so we
  do not warn-spam when the key already exists.
- Tighten the trust gate from github.event_name != 'pull_request' to
  github.event_name == 'push' so issue_comment (!snapshot) runs do
  not save the cache. Snapshot CI checks out PR-author-controlled
  code; only push-to-main is a structurally trusted save context.
Replaces inline oven-sh/setup-bun@v2 + actions/cache(/restore)@v5 +
bun install steps with a single ./.github/actions/setup-bun reference.
Combined with the composite's split restore/save and the github.event_name
== 'push' trust gate, this resolves the 9 CodeQL alerts
(actions/cache-poisoning/poisonable-step #29-#37) in ci.yml. The test-e2e
job is unchanged.
@wyattjoh
Copy link
Copy Markdown
Contributor Author

Stack: wyattjoh/refactor-setup-bun-cache

Part of a stacked PR chain. Do not merge manually.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

⚠️ No Changeset found

Latest commit: f56e9a0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@wyattjoh wyattjoh changed the title wyattjoh/refactor setup bun cache refactor(ci): use setup-bun composite for cache flow May 12, 2026
Comment thread .github/actions/setup-bun/action.yml Fixed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The setup-bun composite action now documents only "none" and "restore" and uses a restore-only cache step when inputs.cache == "restore". CI jobs (Build, Lint, Test, E2E) gate Bun cache restores on github.event_name != 'issue_comment' and continue to run bun install. Added warm-bun-cache.yml to populate the Bun install cache on pushes to main. Several workflows (notify-failure, notify-release, release jobs) now use oven-sh/setup-bun@v2 with explicit cache restore and bun install steps.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main changes: refactoring the CI setup by inlining the setup-bun action and gating cache behavior on event type to address snapshot security concerns.
Description check ✅ Passed The description provides detailed context about the changes: dropping the composite action, inlining its operations at call sites, gating cache restore in ci.yml, delegating cache population to warm-bun-cache.yml, and explaining the security motivation (snapshot path in privileged context).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/actions/setup-bun/action.yml (1)

30-40: ⚡ Quick win

Make the save-gate comment match the actual condition.

The comment says this saves “only on push to main,” but the guard only checks github.event_name == 'push'. Either add the branch check or relax the wording so future hardening work is based on the real behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/actions/setup-bun/action.yml around lines 30 - 40, The comment above
the "Save Bun cache" step is misleading: it says "Save only on push to main" but
the actual if uses inputs.cache, github.event_name == 'push', and
steps.bun-cache.outputs.cache-hit != 'true' (no branch check). Either update the
plain-text comment to reflect the real guard (mentioning inputs.cache ==
'read-write', github.event_name == 'push', and skip-on-cache-hit) or change the
if expression to include a branch restriction (e.g., add github.ref ==
'refs/heads/main') so the behavior matches the comment; adjust the comment or
the if on the "Save Bun cache" step accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/actions/setup-bun/action.yml:
- Around line 30-40: The comment above the "Save Bun cache" step is misleading:
it says "Save only on push to main" but the actual if uses inputs.cache,
github.event_name == 'push', and steps.bun-cache.outputs.cache-hit != 'true' (no
branch check). Either update the plain-text comment to reflect the real guard
(mentioning inputs.cache == 'read-write', github.event_name == 'push', and
skip-on-cache-hit) or change the if expression to include a branch restriction
(e.g., add github.ref == 'refs/heads/main') so the behavior matches the comment;
adjust the comment or the if on the "Save Bun cache" step accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d0d046bf-8ca5-43a0-8b28-95fa159e0fbf

📥 Commits

Reviewing files that changed from the base of the PR and between 58a431d and 2ae9152.

📒 Files selected for processing (2)
  • .github/actions/setup-bun/action.yml
  • .github/workflows/ci.yml

The setup-bun composite previously contained a conditional cache save
step. Even gated to push contexts, the save action's structural presence
in a job reachable from a workflow_call that ultimately traces back to
issue_comment (the !snapshot path) is enough for CodeQL's cache-poisoning
rule to flag every step in the job.

Move the cache save into a dedicated warm-bun-cache.yml workflow
triggered only by push to main. The composite becomes restore-only and
its read-write mode is removed (no callers used it after this refactor's
build job switched to restore). PR runs read main's warmed cache via
restore-keys fallback; the warmup workflow rebuilds the cache whenever
bun.lock changes on main.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/workflows/warm-bun-cache.yml (1)

10-12: ⚡ Quick win

Include setup-bun action changes in warm-cache triggers.

Line 10-12 path filters currently skip .github/actions/setup-bun/action.yml; if cache key/path logic changes there, warm-up may not run after merge and CI stays cold until bun.lock changes.

Suggested diff
 on:
   push:
     branches: [main]
     paths:
       - bun.lock
+      - .github/actions/setup-bun/action.yml
       - .github/workflows/warm-bun-cache.yml
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/warm-bun-cache.yml around lines 10 - 12, The workflow's
paths filter under the "paths" key only lists bun.lock and the warm-bun-cache
workflow itself, so changes to the setup-bun action won't trigger the warm
cache; update the "paths" array to include the setup-bun action file so edits to
that action will retrigger the warm-cache job (add the setup-bun action entry to
the paths list next to bun.lock and .github/workflows/warm-bun-cache.yml).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/workflows/warm-bun-cache.yml:
- Around line 10-12: The workflow's paths filter under the "paths" key only
lists bun.lock and the warm-bun-cache workflow itself, so changes to the
setup-bun action won't trigger the warm cache; update the "paths" array to
include the setup-bun action file so edits to that action will retrigger the
warm-cache job (add the setup-bun action entry to the paths list next to
bun.lock and .github/workflows/warm-bun-cache.yml).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 250e1e85-6e45-4b35-be19-7e125e9a3e17

📥 Commits

Reviewing files that changed from the base of the PR and between 2ae9152 and 35230d6.

📒 Files selected for processing (3)
  • .github/actions/setup-bun/action.yml
  • .github/workflows/ci.yml
  • .github/workflows/warm-bun-cache.yml

wyattjoh added 2 commits May 12, 2026 17:10
Removes the .github/actions/setup-bun composite action and inlines its
operations (oven-sh/setup-bun@v2, optional actions/cache/restore@v5,
bun install --frozen-lockfile) at all eight call sites.

In ci.yml's build, lint, test, and test-e2e jobs, the cache restore is
gated on github.event_name != 'issue_comment' so the snapshot path (which
checks out PR-author-controlled code in the default branch's privileged
context via release.yml's workflow_call) cannot read the cache. Other
workflows (release.yml versioning/canary-version, notify-failure,
notify-release) inline directly without a gate because they only run on
trusted triggers.
Both notify-failure and notify-release run on push-to-main triggered
release workflows where the cache is already warm; adding the restore
step avoids a cold install on every notification job.
@wyattjoh wyattjoh changed the title refactor(ci): use setup-bun composite for cache flow refactor(ci): inline bun setup, gate cache on snapshot May 12, 2026
@brkalow brkalow requested a review from Zertsov May 13, 2026 15:25
@wyattjoh wyattjoh merged commit 235c476 into main May 13, 2026
10 checks passed
@wyattjoh wyattjoh deleted the wyattjoh/refactor-setup-bun-cache branch May 13, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants